package main

import "fmt"

//go   组合实现继承
type Teacher struct {
	Name  string
	Age   int
	Title string
}

func (t Teacher) teacherInfo() {
	fmt.Printf("姓名：%s，年龄：%d，职称：%s", t.Name, t.Age, t.Title)
}

type Course struct {
	//匿名嵌套
	Teacher
	Name  string
	Price int
	Url   string
}

func (c Course) courseInfo() {
	fmt.Printf("课程名：%s，价格：%d，讲师信息：%s %d %s", c.Name, c.Price, c.Teacher.Name, c.Age, c.Title)
}

func main() {
	t := Teacher{
		Name:  "bobby",
		Age:   18,
		Title: "开发",
	}
	c := Course{
		Teacher: t,
		Price:   100,
		Url:     "",
		Name:    "django",
	}
	c.courseInfo()
}
